package com.exam.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * 
 */
public class GenericsUtils {

	/**
	 * @param clazz
	 * @return 类对象
	 */
	public static Class getGenericClass(Class clazz) {
		Type genType = clazz.getGenericSuperclass();

		if (genType instanceof ParameterizedType) {
			Type[] params = ((ParameterizedType) genType)
					.getActualTypeArguments();

			if ((params != null) && (params.length == 1)) {
				return (Class) params[0];
			}
		}

		return null;
	}
}
